/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package introse;

import com.sun.net.ssl.internal.ssl.Debug;

public class source {
    
    private int sourceNumber;
    private String sourceName;
    private boolean isActive;
    
    public source(int sourceNumber, String sourceName, boolean isActive){
        this.sourceNumber = sourceNumber;
        this.sourceName = sourceName;
        this.isActive = isActive;
    }
    
    public int getSourceNumber(){
        return sourceNumber;
    }
    
    public String getSourceName(){
        return sourceName;
    }
    
    public boolean getIsActive(){
        return isActive;
    }
    
    public boolean setName(String sourceName){
        databaseConn conn = new databaseConn();
        if(conn.sqlStatement(String.format("UPDATE `sashmirgasul`.`source` SET `sourceName`='%s' WHERE `sourceNumber`='%d';", sourceName, this.getSourceNumber()))){
            this.sourceName = sourceName;
            return true;
        }
        else{
            return false;
        }
    }
    
    public boolean setIsActive(boolean isActive){
        databaseConn conn = new databaseConn();
        if(conn.sqlStatement(String.format("UPDATE `sashmirgasul`.`source` SET `isActive`=%d WHERE `sourceNumber`='%d';", isActive? 1 : 0, this.getSourceNumber()))){
            this.isActive = isActive;
            return true;
        }
        else{
            return false;
        }
    }
    
}
